package cn.wolfcode.luowowo.comment.domain;

import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

@Getter@Setter
@Document("scenicspot_comment")
public class ScenicspotComment implements Serializable{
    public static final int TRAVLE_COMMENT_TYPE_COMMENT = 0; //普通评论
    public static final int TRAVLE_COMMENT_TYPE = 1; //评论的评论
    public static final int GOOD_COMMENTS = 0; //好评
    public static final int MIDDLE_COMMENTS = 1; //中评
    public static final int BAD_COMMENTS = 2; //差评

    @Id
    private String id;  //id
    private Long scenicspotId; //景点id
    private String scenicspotName;//景点name
    private int totalScore; //总评分
    private int viewScore; //风光评分
    private int characterScore;//特色
    private int serviceScore;//服务
    private String comment;  //评论内容
    private String images;   //评价图片
    private int thumbNum;
    private boolean hasImg = false;

    private Long userId;    //用户id
    private String username; //用户名
    private String headUrl;   // 用户头像
    private int level;

    private Date createTime; //创建时间
    private int type = TRAVLE_COMMENT_TYPE_COMMENT; //评论类别
    private List<ScenicspotReply> reply = new ArrayList<>();  //关联的回复

    public int getCommentType(){
        if(totalScore == 1){
            return BAD_COMMENTS;
        }else if (totalScore == 2 || totalScore == 3){
            return MIDDLE_COMMENTS;
        }else {
            return GOOD_COMMENTS;
        }
    }

    public List<String> getImgList(){
        if(StringUtils.hasLength(images)){
            String[] split = images.split(",");
            List<String> list = new ArrayList<>(split.length);
            Collections.addAll(list,split);
            return list;
        }
        return null;
    }

    private String ename;//拼音名
    private String coverUrl;//景点图片

}
